const btn = document.querySelector('#btn')
btn.addEventListener('click', () => {
    const xhr = new XMLHttpRequest()
    xhr.open('Get', 'http://127.0.0.1:8888/server')
    xhr.send()
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4) {
            console.log('请求完毕，服务端返回结果')
            if (xhr.status >= 200 && xhr.status < 300) {
                const result = document.querySelector('#result')
                result.innerHTML = xhr.response
            }
        }
    }
})